package cn.slipi.admin.service.impl;

import cn.slipi.admin.common.exception.base.BizException;
import cn.slipi.admin.dao.TSysRolePermissionMapper;
import cn.slipi.admin.entity.TSysRolePermission;
import cn.slipi.admin.service.TSysRolePermissionService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * <p>
 * 系统角色与权限对应关系表 服务实现类
 * </p>
 *
 * @author lee
 * @since 2020-10-09
 */
@Service
public class TSysRolePermissionServiceImpl extends ServiceImpl<TSysRolePermissionMapper, TSysRolePermission> implements TSysRolePermissionService {
    @Override
    @Transactional(rollbackFor = BizException.class)
    public List<TSysRolePermission> getRolePermissionByRoleIds(List<Integer> roleIds) {
        /**
         * select rp from RolePermission rp where rp.roleId in(:roleIds) and rp.status = 1
         */
        QueryWrapper<TSysRolePermission> queryWrapper = new QueryWrapper<>();
        queryWrapper.in("ROLE_ID", roleIds);
        queryWrapper.eq("STATUS", 1);
        return this.baseMapper.selectList(queryWrapper);
    }
}
